/*
  学习目标：掌握setState更新
*/

import React, { Component } from 'react';

export default class App extends Component {
  state = {
    count: 0,
  };

  handleClick = () => {
    // setState是异步的
    // 合并:  连续调用setState更新同一个状态, 会产生覆盖的效果
    this.setState({ count: this.state.count + 1 });
    this.setState({ count: this.state.count + 2 });
    this.setState({ count: this.state.count + 3 });
  };

  render() {
    console.log('render  ----->  ');
    return (
      <div>
        <h1>{this.state.count}</h1>
        <button onClick={this.handleClick}>点我</button>
      </div>
    );
  }
}
